package com.tiantian.quanminxiu.module;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.tiantian.quanminxiu.R;
import com.tiantian.quanminxiu.utils.APPUtils;


/*
* 底部模块
* */
public class Module_Footer extends LinearLayout {

    //region 初始化成员和视图组件
    public View vFooter_Hall,vFooter_Live,vFooter_Attention,vFooter_Ranking,vFooter_Mine;
    public ImageView imgFooter_Hall_Icon,imgFooter_Attention_Icon,imgFooter_Ranking_Icon,imgFooter_Mine_Icon;
    public TextView txtFooter_Hall_Text,txtFooter_Attention_Text,txtFooter_Ranking_Text,txtFooter_Mine_Text;
    private int intLastChannelIndex = -1;

    private Context context;
    //endregion

    //region 模块类构造器(一个参数和两个参数)
    public Module_Footer(Context context) {
        this(context, null);
    }

    public Module_Footer(Context context, AttributeSet attrs) {
        super(context, attrs);
        this.context = context;
        LayoutInflater.from(context).inflate(R.layout.module_footer, this, true);

        vFooter_Hall = findViewById(R.id.vFooter_Hall);
        vFooter_Attention = findViewById(R.id.vFooter_Attention);
        vFooter_Live = findViewById(R.id.vFooter_Live);
        vFooter_Ranking = findViewById(R.id.vFooter_Ranking);
        vFooter_Mine = findViewById(R.id.vFooter_Mine);

        imgFooter_Hall_Icon = (ImageView) findViewById(R.id.imgFooter_Hall_Icon);
        imgFooter_Attention_Icon = (ImageView) findViewById(R.id.imgFooter_Attention_Icon);
        imgFooter_Ranking_Icon = (ImageView) findViewById(R.id.imgFooter_Ranking_Icon);
        imgFooter_Mine_Icon = (ImageView) findViewById(R.id.imgFooter_Mine_Icon);

        txtFooter_Hall_Text = (TextView) findViewById(R.id.txtFooter_Hall_Text);
        txtFooter_Attention_Text = (TextView) findViewById(R.id.txtFooter_Attention_Text);
        txtFooter_Ranking_Text = (TextView) findViewById(R.id.txtFooter_Ranking_Text);
        txtFooter_Mine_Text = (TextView) findViewById(R.id.txtFooter_Mine_Text);

        // 初始选择频道
        Channel(0);
    }
    //endregion

    //region 频道选择函数 Channel(int ChannelIndex)
    @SuppressWarnings("deprecation")
    public void
    Channel(int ChannelIndex) {
        if (intLastChannelIndex == ChannelIndex) {
            return;
        }
        switch (intLastChannelIndex) {
            case 0:
                //取消某个图片
                imgFooter_Hall_Icon.setImageResource(R.drawable.icon_menu_hall);
                txtFooter_Hall_Text.setTextColor(APPUtils.getResourcesColor(context,R.color.grey3));
                break;
            case 1:
                imgFooter_Attention_Icon.setImageResource(R.drawable.icon_menu_attention);
                txtFooter_Attention_Text.setTextColor(APPUtils.getResourcesColor(context, R.color.grey3));
                break;
            case 2:
                //取消某个图片
                imgFooter_Ranking_Icon.setImageResource(R.drawable.icon_menu_ranking);
                txtFooter_Ranking_Text.setTextColor(APPUtils.getResourcesColor(context, R.color.grey3));
                break;
            case 3:
                imgFooter_Mine_Icon.setImageResource(R.drawable.icon_menu_mine);
                txtFooter_Mine_Text.setTextColor(APPUtils.getResourcesColor(context, R.color.grey3));
                break;

        }
        switch (ChannelIndex) {
            case 0:
                //点击效果图片
                imgFooter_Hall_Icon.setImageResource(R.drawable.icon_menu_hall_press);
                txtFooter_Hall_Text.setTextColor(APPUtils.getResourcesColor(context, R.color.wihte));
                break;
            case 1:
                imgFooter_Attention_Icon.setImageResource(R.drawable.icon_menu_attention_press);
                txtFooter_Attention_Text.setTextColor(APPUtils.getResourcesColor(context, R.color.wihte));
                break;
            case 2:
                //点击效果图片
                imgFooter_Ranking_Icon.setImageResource(R.drawable.icon_menu_ranking_press);
                txtFooter_Ranking_Text.setTextColor(APPUtils.getResourcesColor(context, R.color.wihte));
                break;
            case 3:
                imgFooter_Mine_Icon.setImageResource(R.drawable.icon_menu_mine_press);
                txtFooter_Mine_Text.setTextColor(APPUtils.getResourcesColor(context, R.color.wihte));
                break;
        }
        intLastChannelIndex = ChannelIndex;
    }
    //endregion

    //region 隐藏组件 Hide()
    public void Hide() {

    }
    //endregion

    //region 展示组件 Show()
    public void Show() {

    }
    //endregion
}